﻿using System;
using System.Collections.Generic;
using System.IO;

namespace dota2itemchanger
{
    class Hero
    {
        public string name;
        public string image;
        public Hero(string name, string image)
        {
            this.name = name;
            this.image = image;
        }
        public string RealImage()
        {
            string s = Directory.GetCurrentDirectory() + "\\images\\heroes\\" + image + ".png";
            return s;
        }
    }

    class Heroes
    {
        static List<Hero> heroes = new List<Hero>();

        public static void Load()
        {
            StreamReader sr = new StreamReader(@"heroes.csv");
            char[] sep = { ';' };
            string line;
            string[] values;
            while (!sr.EndOfStream)
            {
                line = sr.ReadLine();
                values = line.Split(sep);
                if (values.Length != 2)
                {
                    continue;
                }
                heroes.Add(new Hero(values[0], values[1]));
            }
            sr.Close();
        }

        public static Hero GetHero(string name)
        {
            foreach (Hero h in heroes)
            {
                if (h.name == name)
                {
                    return h;
                }
            }
            return null;
        }

        public static List<Hero> AllHeroes()
        {
            return heroes;
        }
    }
}
